<template>
  <div class="app-container">
    <template v-if="$route.meta.requiresLayout === true">
      <Header />
      <main class="main-content">
        <router-view></router-view>
      </main>
      <Footer />
    </template>
    <template v-else-if="$route.meta.requiresLayout === 'header-only'">
      <Header />
      <main class="main-content">
        <router-view></router-view>
      </main>
    </template>
    <template v-else-if="$route.meta.requiresLayout === 'footer-only'">
      <main class="main-content">
        <router-view></router-view>
      </main>
      <Footer />
    </template>
    <template v-else>
      <div class="fullscreen-view">
        <router-view></router-view>
      </div>
    </template>
  </div>
</template>

<script setup>
import Header from './components/Header.vue'
import Footer from './components/Footer.vue'
</script>

<style>
/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  width: 100vw;
  overflow-x: hidden;
}

/* 优化滚动条性能 */
::-webkit-scrollbar {
  width: 8px;
  height: 0;
}

::-webkit-scrollbar-thumb {
  background-color: #c1c1c1;
  border-radius: 4px;
  will-change: transform;
}

::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}

body {
  -ms-overflow-style: auto;  /* IE and Edge */
  scrollbar-width: thin;  /* Firefox */
  overflow-x: hidden; /* 禁止横向滚动 */
}

.main-content {
  flex: 1;
}

.fullscreen-view {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f5f7fa;
}

/* 移动端层级修复 */
@media (max-width: 768px) {
  .app-container {
    position: relative;
    z-index: 1;
  }
  
  .main-content {
    position: relative;
    z-index: 1;
  }
  
  /* 确保抽屉菜单在最顶层 */
  .el-drawer,
  .el-drawer__wrapper,
  .el-overlay {
    z-index: 9999999 !important;
  }
}
</style>
